package com.hylanda.sys.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.validation.constraints.NotNull;

import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import org.springframework.format.annotation.DateTimeFormat;

import com.hylanda.util.annotation.HyTable;

/**
 * The persistent class for the u_permission database table.
 * 
 */
@HyTable(name="u_permission")
public class UPermission implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;

	private String name;

	private String url;

	@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@Column(name="create_time")
	private Date createTime;
	public UPermission getParent() {
		return parent;
	}

	public void setParent(UPermission parent) {
		this.parent = parent;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getPriority() {
		return priority;
	}

	public void setPriority(Integer priority) {
		this.priority = priority;
	}

//	public List<UPermission> getChildren() {
//		return children;
//	}
//
//	public void setChildren(List<UPermission> children) {
//		this.children = children;
//	}
	@ManyToOne
	@JoinColumn(name="parentId")
	private UPermission parent;
	@Length(max=255)
	@Column(length=255)
	private String description;
	@NotNull
	@Range(min=1, max=99)
	@Column(length=2)
	private Integer priority = 99;
	public UPermission() {
	}
//	@OneToMany(cascade={CascadeType.PERSIST, CascadeType.REMOVE}, mappedBy="parent")
//	@OrderBy("priority ASC")
//	private List<UPermission> children = Lists.newArrayList();

	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getUrl() {
		return this.url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}


}